package com.v.im.webservice.controller.user;


import com.v.im.businessapi.dto.resultDTO.ImUserResultDTO;
import com.v.im.commonmodule.utils.bean.CurrentUserInfo;
import com.v.im.webservice.controller.base.BaseController;
import com.v.im.webservice.dto.resultDTO.UserInitResultDTO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/api/user")
public class ImUserController extends BaseController {


    /**
     * 用户信息初始化
     *
     * @param request request
     * @return json
     */
    @PostMapping("init")
    public UserInitResultDTO getUserInitInfo(HttpServletRequest request) {
        CurrentUserInfo currentUserInfo = getCurrentUserInfo(request);
        return imUserService.getUserInitInfo(currentUserInfo.getUserName(), request);
    }


    /**
     * 获取群组的用户
     *
     * @param chatId 群组id
     * @return 用户List
     */
    @RequestMapping("chatUserList")
    public List<ImUserResultDTO> chatUserList(String chatId) {
        return imUserService.getChatUserList(chatId);
    }
}
